using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
//using System.Web.Mail;
using System.Text;
using System.Net.Mail;

/// <summary>
/// Summary description for Utilities
/// </summary>
public abstract class Utilities
{
    public static bool SendMail(string emailaddress, string mailcontent, string mailsubject)
    {
        MailMessage onemail = new MailMessage();
        string myEmail = ConfigurationManager.AppSettings["from"].ToString();
        string myPwd = ConfigurationManager.AppSettings["password"].ToString();
        string userName = ConfigurationManager.AppSettings["username"].ToString();
        onemail.BodyEncoding = System.Text.Encoding.UTF8;
        onemail.IsBodyHtml = true;
        onemail.From = new MailAddress(myEmail);
        onemail.To.Add(new MailAddress(emailaddress));
        onemail.Subject = mailsubject;
        onemail.Body = mailcontent;
        onemail.BodyEncoding = System.Text.Encoding.UTF8;
        SmtpClient clint = new SmtpClient(ConfigurationManager.AppSettings["smtpserver"].ToString());
        clint.UseDefaultCredentials = false;
        clint.Credentials = new System.Net.NetworkCredential(userName, myPwd);
        clint.DeliveryMethod = SmtpDeliveryMethod.Network;

        clint.Port = 587; //gmail

        clint.EnableSsl = true;

        try
        {
            clint.Send(onemail);
            return true;
        }
        catch (Exception ex)
        {
            return false;
        }
    }

}
